/**
 * 
 */
package com.conan.zone.rss.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.conan.zone.framework.dao.IAbstractDao;
import com.conan.zone.framework.service.impl.AbstractServiceImpl;
import com.conan.zone.rss.dao.IRssItemDao;
import com.conan.zone.rss.model.RssItem;
import com.conan.zone.rss.service.IRssItemService;
import com.conan.zone.rss.support.Rss;

/**
 * @author Conan
 *
 */
@Service
public class RssItemServiceImpl extends AbstractServiceImpl<RssItem> implements IRssItemService {
	@Resource
	@Qualifier("rssItemDaoImpl")
	private IRssItemDao iRssItemDao;
	
	@Override
	@Resource
	@Qualifier("rssItemDaoImpl")
	public void setiAbstractDao(IAbstractDao<RssItem> iAbstractDao) {
		super.setiAbstractDao(iAbstractDao);
	}

	@Override
	public String tableJson(RssItem t, String sEcho, List<RssItem> list) {
		return null;
	}

	@Override
	public void doImportRss() {
		List<Rss.RssObj> list = Rss.allRssObj();
		for (final Rss.RssObj rssObj : list) {
			executor.execute(new Runnable(){
				@Override
				public void run() {
					List<RssItem> itemList = rssObj.getParser().parser(rssObj.getLink());
					for (RssItem item : itemList) {
						iRssItemDao.insertObj(item);
					}
				}
			});
		}
		executor.shutdown();
	}
}
